﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SiteMain.Master" AutoEventWireup="true"
    CodeBehind="Registrar.aspx.cs" Inherits="ShoppingCart.WebSite.Registrar" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script type="text/javascript">
        function ValidarForm() {
            var val = true;
            var email = document.getElementById('<%= txtEmail.ClientID %>').value;
            var pattern = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;

            if (document.getElementById('<%= txtNumeroDocumento.ClientID %>').value == '') {
                val = false;
            }

            if (document.getElementById('<%= txtNombres.ClientID %>').value == '') {
                val = false;
            }

            if (document.getElementById('<%= txtApellidos.ClientID %>').value == '') {
                val = false;
            }

            if (document.getElementById('<%= txtEmail.ClientID %>').value == '') {
                val = false;
            } else {
                if (pattern.test(email)) {
                    val = val;
                } else {
                    val = false;
                }
            }

            if (document.getElementById('<%= txtDireccion.ClientID %>').value == '') {
                val = false;
            }

            if (!val) {
                alert('Debe completar correctamente los campos que son obligatorios(*).');
                return false;
            }
            else {
                return true;
            }
        }      
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="RightSide">
        <div class="bredCrum">
            <h4>
                <a class="select">Datos del Comprador</a>
            </h4>
        </div>
        <asp:UpdatePanel ID="upCliente" runat="server">
            <ContentTemplate>
                <fieldset style="padding: 10px; padding-left: 20px;">
                    <legend>Ingresar los datos para realizar la compra: </legend>
                    <br />
                    <table cellspacing="5">
                        <tr>
                            <td align="center" rowspan="4" valign="middle" style="width: 150px;">
                                <asp:Image ID="imgFoto" runat="server" ImageUrl="~/Style/images/cliente.png" Height="128px"
                                    Width="128px" />
                            </td>
                            <%--<td>
                                Tipo Doc.<br />
                                <asp:DropDownList ID="ddlTipoDocumento" runat="server" Width="60px">
                                    <asp:ListItem>DNI</asp:ListItem>
                                    <asp:ListItem>RUC</asp:ListItem>
                                </asp:DropDownList>
                            </td>--%>
                            <td colspan="2">
                                Número DNI <b>(*)</b><br />
                                <asp:TextBox ID="txtNumeroDocumento" runat="server" MaxLength="11" Width="160px"
                                    AutoPostBack="True" OnTextChanged="TxtNumeroDocumentoTextChanged"></asp:TextBox>
                                <cc1:MaskedEditExtender ID="meeDNI" TargetControlID="txtNumeroDocumento"
                                    runat="server" Mask="99999999" MaskType="Number" />
                                <cc1:TextBoxWatermarkExtender ID="tbwNumeroDocumento" runat="server" TargetControlID="txtNumeroDocumento"
                                    WatermarkText="Número" WatermarkCssClass="watermarked" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Nombres <b>(*)</b><br />
                                <asp:TextBox ID="txtNombres" runat="server" Width="160px"></asp:TextBox>
                                <cc1:TextBoxWatermarkExtender ID="tbwNombres" runat="server" TargetControlID="txtNombres"
                                    WatermarkText="Ingresar su Nombre" WatermarkCssClass="watermarked" />
                            </td>
                            <td>
                                Apellidos <b>(*)</b><br />
                                <asp:TextBox ID="txtApellidos" runat="server" Width="252px"></asp:TextBox>
                                <cc1:TextBoxWatermarkExtender ID="tbwApellidos" runat="server" TargetControlID="txtApellidos"
                                    WatermarkText="Ingresar sus Apellidos" WatermarkCssClass="watermarked" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                E-mail <b>(*)</b><br />
                                <asp:TextBox ID="txtEmail" runat="server" Width="418px"></asp:TextBox>
                                <cc1:TextBoxWatermarkExtender ID="tbwEmail" runat="server" TargetControlID="txtEmail"
                                    WatermarkText="Direccion de correo" WatermarkCssClass="watermarked" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                RUC<br />
                                <asp:TextBox ID="txtRuc" runat="server" Width="160px" MaxLength="11"></asp:TextBox>
                                <cc1:MaskedEditExtender ID="meeRUC" TargetControlID="txtRuc"
                                    runat="server" Mask="99999999999" MaskType="Number" />
                                <cc1:TextBoxWatermarkExtender ID="tbwRuc" runat="server" TargetControlID="txtRuc"
                                    WatermarkText="Numero RUC" WatermarkCssClass="watermarked" />
                            </td>
                            <td>
                                Raz&oacute;n Social<br />
                                <asp:TextBox ID="txtRazonSocial" runat="server" Width="252px"></asp:TextBox>
                                <cc1:TextBoxWatermarkExtender ID="tbwRazonSocial" runat="server" TargetControlID="txtRazonSocial"
                                    WatermarkText="Ingresar su Razón Social" WatermarkCssClass="watermarked" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Departamento <b>(*)</b><br />
                                <asp:DropDownList ID="ddlDepartamento" runat="server" Width="140px" AutoPostBack="True"
                                    OnSelectedIndexChanged="DdlDepartamentoSelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                            <td>
                                Provincia <b>(*)</b><br />
                                <asp:DropDownList ID="ddlProvincia" runat="server" Width="140px" AutoPostBack="True"
                                    OnSelectedIndexChanged="DdlProvinciaSelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                            <td>
                                Distrito <b>(*)</b><br />
                                <asp:DropDownList ID="ddlDistrito" runat="server" Width="200px">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                Direcci&oacute;n <b>(*)</b><br />
                                <asp:TextBox ID="txtDireccion" runat="server" Width="520px"></asp:TextBox>
                                <cc1:TextBoxWatermarkExtender ID="tbwDireccion" runat="server" TargetControlID="txtDireccion"
                                    WatermarkText="Ingresar su direccion" WatermarkCssClass="watermarked" />
                            </td>
                        </tr>
                    </table>
                    <br />
                </fieldset>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="txtNumeroDocumento" EventName="Textchanged" />
                <asp:AsyncPostBackTrigger ControlID="ddlDepartamento" EventName="Selectedindexchanged" />
                <asp:AsyncPostBackTrigger ControlID="ddlProvincia" EventName="Selectedindexchanged" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
    <div class="RightSide">
        <div class="paging">
            <div style="float: left;">
                Los datos con (*) deben ser ingresados.
            </div>
            <div class="pagingDiv" style="width: 200px;">
                <span class="back">
                    <asp:LinkButton ID="btnRegresar" runat="server" PostBackUrl="~/Default.aspx"><img src="Style/images/back.gif" alt="" /> Regresar</asp:LinkButton>
                </span>&nbsp;|&nbsp;<span class="next">
                    <asp:LinkButton ID="btnContinuar" runat="server" OnClick="BtnContinuarClick" OnClientClick="return ValidarForm();">Continuar <img src="Style/images/next.gif" alt="" /></asp:LinkButton>
                </span>
            </div>
        </div>
    </div>
    <div class="clr">
    </div>
</asp:Content>
